<%--
  Created by IntelliJ IDEA.
  User: Doris丶Lee
  Date: 2020-05-20
  Time: 08:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%--URLDecoder的包，里面包含解码工具类，避免输入中文导致乱码--%>
<%@ page import="java.net.*" %>
<html>
<head>
    <title>用户中心</title>
</head>
<body>
    <h1>用户信息</h1>
    <hr>
    <%
        request.setCharacterEncoding("utf-8");


        //获取cookie信息
        String username="";
        String password = "";
        Cookie[] cookies = request.getCookies();
        if(cookies!=null&&cookies.length>0)
        {
            for(Cookie c:cookies)
            {
                //URL解码
                if(c.getName().equals("username"))//保存过
                {
                    //username = c.getValue();
                    username = URLDecoder.decode(c.getValue(),"utf-8");
                }
                if(c.getName().equals("password"))
                {
                    //password = c.getValue();
                    password = URLDecoder.decode(c.getValue(),"utf-8");
                }
            }
        }
    %>
    <BR>
    <BR>
    <BR>
    用户名：<%=username %><br>
    密码：<%=password %><br>
</body>
</html>
